import time


# TL032FWV01-I1440A 320 x 820 bar display
def init(self):
    param_buf = bytearray(16)
    param_mv = memoryview(param_buf)
    
    # Sleep Out
    self.set_params(0x11)

    time.sleep_ms(100)  # NOQA

    param_buf[:5] = bytearray([0x77, 0x01, 0x00, 0x00, 0x13])
    self.set_params(0xFF, param_mv[:5])

    param_buf[0] = 0x08
    self.set_params(0xEF, param_mv[:1])

    param_buf[:5] = bytearray([0x77, 0x01, 0x00, 0x00, 0x10])
    self.set_params(0xFF, param_mv[:5])

    param_buf[:2] = bytearray([0xE5, 0x02])
    self.set_params(0xC0, param_mv[:2])

    # VBP
    param_buf[:2] = bytearray([0x0C, 0x0A])
    self.set_params(0xC1, param_mv[:2])

    param_buf[:2] = bytearray([0x07, 0x0F])
    self.set_params(0xC2, param_mv[:2])

    param_buf[0] = 0x02
    self.set_params(0xC2, param_mv[:1])

    param_buf[0] = 0x10
    self.set_params(0xCC, param_mv[:1])

    param_buf[0] = 0x08
    self.set_params(0xCD, param_mv[:1])

    param_buf[:16] = bytearray([
        0x00, 0x08, 0x51, 0x0D, 0xCE, 0x06, 0x00, 0x08, 
        0x08, 0x1D, 0x02, 0xD0, 0x0F, 0x6F, 0x36, 0x3F])
    self.set_params(0xB0, param_mv[:16])

    param_buf[:16] = bytearray([
        0x00, 0x10, 0x4F, 0x0C, 0x11, 0x05, 0x00, 0x07, 
        0x07, 0x1F, 0x05, 0xD3, 0x11, 0x6E, 0x34, 0x3F])
    self.set_params(0xB1, param_mv[:16])

    param_buf[:5] = bytearray([0x77, 0x01, 0x00, 0x00, 0x11])
    self.set_params(0xFF, param_mv[:5])

    param_buf[0] = 0x4D
    self.set_params(0xB0, param_mv[:1])

    param_buf[0] = 0x1C
    self.set_params(0xB1, param_mv[:1])

    param_buf[0] = 0x87
    self.set_params(0xB2, param_mv[:1])

    param_buf[0] = 0x80
    self.set_params(0xB3, param_mv[:1])

    param_buf[0] = 0x47
    self.set_params(0xB5, param_mv[:1])

    param_buf[0] = 0x85
    self.set_params(0xB7, param_mv[:1])

    param_buf[0] = 0x21
    self.set_params(0xB8, param_mv[:1])

    param_buf[0] = 0x10
    self.set_params(0xB9, param_mv[:1])

    param_buf[0] = 0x78
    self.set_params(0xC1, param_mv[:1])

    param_buf[0] = 0x78
    self.set_params(0xC2, param_mv[:1])

    param_buf[0] = 0x88
    self.set_params(0xD0, param_mv[:1])

    time.sleep_ms(100)  # NOQA

    param_buf[:3] = bytearray([0x80, 0x00, 0x02])
    self.set_params(0xE0, param_mv[:3])

    param_buf[:11] = bytearray([
        0x04, 0xA0, 0x00, 0x00, 0x05, 0xA0, 
        0x00, 0x00, 0x00, 0x60, 0x60])
    self.set_params(0xE1, param_mv[:11])

    param_buf[:13] = bytearray([
        0x30, 0x30, 0x60, 0x60, 0x3C, 0xA0, 0x00, 
        0x00, 0x3D, 0xA0, 0x00, 0x00, 0x00])
    self.set_params(0xE2, param_mv[:13])

    param_buf[:4] = bytearray([0x00, 0x00, 0x33, 0x33])
    self.set_params(0xE3, param_mv[:4])

    param_buf[:2] = bytearray([0x44, 0x44])
    self.set_params(0xE4, param_mv[:2])

    param_buf[:16] = bytearray([
        0x06, 0x3E, 0xA0, 0xA0, 0x08, 0x40, 0xA0, 0xA0, 
        0x0A, 0x42, 0xA0, 0xA0, 0x0C, 0x44, 0xA0, 0xA0])
    self.set_params(0xE5, param_mv[:16])

    param_buf[:4] = bytearray([0x00, 0x00, 0x33, 0x33])
    self.set_params(0xE6, param_mv[:4])

    param_buf[:2] = bytearray([0x44, 0x44])
    self.set_params(0xE7, param_mv[:2])

    param_buf[:16] = bytearray([
        0x07, 0x3F, 0xA0, 0xA0, 0x09, 0x41, 0xA0, 0xA0, 
        0x0B, 0x43, 0xA0, 0xA0, 0x0D, 0x45, 0xA0, 0xA0])
    self.set_params(0xE8, param_mv[:16])

    param_buf[:7] = bytearray([0x00, 0x01, 0x4E, 0x4E, 0xEE, 0x44, 0x00])
    self.set_params(0xEB, param_mv[:7])

    param_buf[:16] = bytearray([
        0xFF, 0xFF, 0x04, 0x56, 0x72, 0xFF, 0xFF, 0xFF, 
        0xFF, 0xFF, 0xFF, 0x27, 0x65, 0x40, 0xFF, 0xFF])
    self.set_params(0xED, param_mv[:16])

    param_buf[:6] = bytearray([0x10, 0x0D, 0x04, 0x08, 0x3F, 0x1F])
    self.set_params(0xEF, param_mv[:6])

    param_buf[:5] = bytearray([0x77, 0x01, 0x00, 0x00, 0x13])
    self.set_params(0xFF, param_mv[:5])

    param_buf[:2] = bytearray([0x00, 0x0E])
    self.set_params(0xE8, param_mv[:2])

    param_buf[:5] = bytearray([0x77, 0x01, 0x00, 0x00, 0x00])
    self.set_params(0xFF, param_mv[:5])

    self.set_params(0x11)

    time.sleep_ms(120)  # NOQA

    param_buf[:5] = bytearray([0x77, 0x01, 0x00, 0x00, 0x13])
    self.set_params(0xFF, param_mv[:5])

    param_buf[:2] = bytearray([0x00, 0x0C])
    self.set_params(0xE8, param_mv[:2])

    time.sleep_ms(10)  # NOQA

    param_buf[:2] = bytearray([0x00, 0x00])
    self.set_params(0xE8, param_mv[:2])

    param_buf[:5] = bytearray([0x77, 0x01, 0x00, 0x00, 0x00])
    self.set_params(0xFF, param_mv[:5])

    param_buf[0] = 0x00
    self.set_params(0x36, param_mv[:1])

    param_buf[0] = 0x66
    self.set_params(0x3A, param_mv[:1])

    self.set_params(0x11)

    time.sleep_ms(120)  # NOQA

    self.set_params(0x29)

    time.sleep_ms(120)  # NOQA
